bootstrap
目的 Purpose
The bootstrap command is mainly intended to be used by other scripts and enables the ability to bootstrap a Grails application instance outside of the container for usage in tools that require a reference to Grails' ApplicationContext.Examples of its usage include Grails' shell and console使用例 Examples
Add this to the top of your Gant script to use this as an include:includeTargets << grailsScript("_GrailsBootstrap")loadApp- Loads and creates theGrailsApplicationinstanceconfigureApp- Loads all plugins and creates the SpringApplicationContext
loadApp the GrailsApplication instance will be available as the grailsApp variable:loadApp()
for (grailsClass in grailsApp.allClasses) { println grailsClass }configureApp the GrailsPluginManager instance will be available as the pluginManager variable and the Spring ApplicationContext instance will be available as the appCtx variable:configureApp()
Connection c = appCtx.getBean('dataSource').getConnection()
// do something with connection詳細 Description
使用方法: Usage:
grails bootstrap

